using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media.Media3D;

using NewtonDynamics;

namespace WPFPhysics1
{
	public class ButtonBody : RectangleBody
	{
		protected string text;

		public ButtonBody( CCollision collision, double width, double height, string text )
			: base( collision, width, height )
		{
			this.text = text;
		}

		/// <summary>
		/// Create instance
		/// </summary>
		/// <param name="world">World</param>
		/// <param name="width">Width</param>
		/// <param name="height">Height</param>
		/// <returns>New instance</returns>
		public static ButtonBody Create( CWorld world, double mass, double width, double height, double depth, string text )
		{
			CCollisionConvexPrimitives collision = new CCollisionConvexPrimitives( world );
			collision.CreateBox( new Vector3D( width, height, depth ), Matrix3D.Identity );

			ButtonBody body = new ButtonBody( collision, width, height, text );

			InertialMatrix inertialMatrix = collision.CalculateInertialMatrix;

			body.MassMatrix = new MassMatrix( (float)mass, inertialMatrix.m_Inertia * mass );
			body.CentreOfMass = inertialMatrix.m_Origin;

			collision.Release();

			return body;
		}

		public string Text { get { return text; } }
	}
}
